import { createStore } from 'pinia';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
 
export const useStore = createStore({
  id: 'main',
  plugins: [piniaPluginPersistedstate()],
  state: () => ({
    isLoggedIn: false,
    user: null
  }),
  actions: {
    login(user) {
      this.user = user;
      this.isLoggedIn = true;
    },
    logout() {
      this.user = null;
      this.isLoggedIn = false;
    }
  }
});
